package com.honghe.mapper;

import com.github.pagehelper.Page;
import com.honghe.annotation.AutoFill;
import com.honghe.dto.DepartmentPageDTO;
import com.honghe.entity.Department;
import com.honghe.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DepartmentMapper {
    //分页查询相关mapper
    Page<Department> pageQuery(DepartmentPageDTO departmentPageDTO);
    @AutoFill(OperationType.UPDATE)
    void updateById(Department department);
    @AutoFill(OperationType.INSERT)
    void insert(Department department);
    @Select("select * from department where name = #{name};")
    Integer getIdByName(String name);
    @Delete("delete from department where id = #{id};")
    void deleteById(Long id);
    @Select("select id, name, create_time, update_time, create_user, update_user from department where id=#{id};")
    Department getById(Long id);
    @Select("select * from department;")
    List<Department> getAll();
}
